﻿
    using Game.Entity.Enum;
    using Game.Entity.Treasure;
    using Game.Utils;
    using Game.Web.UI;
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

namespace Game.Web.Module.AppManager
{
    partial class SpreadSet : AdminPage
    {
   
        private void BindData()
        {
            GlobalSpreadInfo globalSpreadInfo = base.aideTreasureFacade.GetGlobalSpreadInfo(1);
            if (globalSpreadInfo != null)
            {
                CtrlHelper.SetText(this.txtRegGrantScore, globalSpreadInfo.RegisterGrantScore.ToString());
                CtrlHelper.SetText(this.txtPlayTimeCount, globalSpreadInfo.PlayTimeCount.ToString());
                CtrlHelper.SetText(this.txtPlayTimeGrantScore, globalSpreadInfo.PlayTimeGrantScore.ToString());
                CtrlHelper.SetText(this.txtFillGrantRate, Convert.ToInt32((decimal) (globalSpreadInfo.FillGrantRate * 100M)).ToString());
                CtrlHelper.SetText(this.txtBalanceRate, Convert.ToInt32((decimal) (globalSpreadInfo.BalanceRate * 100M)).ToString());
                CtrlHelper.SetText(this.txtMinBalanceScore, globalSpreadInfo.MinBalanceScore.ToString());
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            base.AuthUserOperationPermission(Permission.Edit);
            double @int = CtrlHelper.GetInt(this.txtFillGrantRate, 0);
            double num2 = CtrlHelper.GetInt(this.txtBalanceRate, 0);
            GlobalSpreadInfo globalSpreadInfo = base.aideTreasureFacade.GetGlobalSpreadInfo(1);
            string  i=   CtrlHelper.GetInt(this.txtRegGrantScore, 0).ToString();
	
		//GlobalSpreadInfo globalSpreadInfo = new GlobalSpreadInfo ();
            if (globalSpreadInfo == null) {
               Response.Write("<script>alert('更新失败')</script>");
                base.ShowError("更新失败");
            }



 		globalSpreadInfo.RegisterGrantScore = CtrlHelper.GetInt(this.txtRegGrantScore, 0);
            globalSpreadInfo.PlayTimeCount = CtrlHelper.GetInt(this.txtPlayTimeCount, 0);
            globalSpreadInfo.PlayTimeGrantScore = CtrlHelper.GetInt(this.txtPlayTimeGrantScore, 0);
            globalSpreadInfo.FillGrantRate = (decimal) (@int / 100.0);
            globalSpreadInfo.BalanceRate = (decimal) (num2 / 100.0);
            globalSpreadInfo.MinBalanceScore = CtrlHelper.GetInt(this.txtMinBalanceScore, 0);
		//Response.Write(globalSpreadInfo.RegisterGrantScore);
                //Response.End();
            try
            {
		Response.Write("<script>alert('更新成功')</script>");
                base.aideTreasureFacade.UpdateGlobalSpreadInfo(globalSpreadInfo);
                base.ShowInfo("更新成功");
            }
            catch
            {
		Response.Write("<script>alert('更新失败')</script>");
                base.ShowError("更新失败");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.BindData();
            }
        }
    }
}

